<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="merchantno" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchantno">
              <a-input v-model="model.merchantno" placeholder="请输入merchantno"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="账号姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountName">
              <a-input v-model="model.accountName" placeholder="请输入账号姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银行名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankName">
              <a-input v-model="model.bankName" placeholder="请输入银行名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银行卡号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankNumber">
              <a-input v-model="model.bankNumber" placeholder="请输入银行卡号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="0失效 1正常" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
              <a-input-number v-model="model.status" placeholder="请输入0失效 1正常" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createtime">
              <j-date placeholder="请选择创建时间" v-model="model.createtime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银行卡类型id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankTypeId">
              <a-input-number v-model="model.bankTypeId" placeholder="请输入银行卡类型id" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银行预留电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
              <a-input v-model="model.phone" placeholder="请输入银行预留电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="userhomeId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userhomeId">
              <a-input-number v-model="model.userhomeId" placeholder="请输入userhomeId" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="0 借记卡 4 贷款卡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="type">
              <a-input-number v-model="model.type" placeholder="请输入0 借记卡 4 贷款卡" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银盛协议号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="protocolno">
              <a-input v-model="model.protocolno" placeholder="请输入银盛协议号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="银盛协议是否有效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isCanProtocol">
              <a-input-number v-model="model.isCanProtocol" placeholder="请输入银盛协议是否有效" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="绑卡标识，提现银行卡对应的绑卡标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="linkid">
              <a-input v-model="model.linkid" placeholder="请输入绑卡标识，提现银行卡对应的绑卡标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="is_wallt=1乡米网内部银行id  外部为0" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userHomeBankId">
              <a-input-number v-model="model.userHomeBankId" placeholder="请输入is_wallt=1乡米网内部银行id  外部为0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否为个人钱包卡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isWallt">
              <a-input-number v-model="model.isWallt" placeholder="请输入是否为个人钱包卡" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="已提取金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="withrawMoney">
              <a-input-number v-model="model.withrawMoney" placeholder="请输入已提取金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'YcYingshengBankForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/bank/ycYingshengBank/add",
          edit: "/bank/ycYingshengBank/edit",
          queryById: "/bank/ycYingshengBank/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>